import requests
from requests import sessions
from random import choice
from json import loads


def _headers():
    Header = [
        {'User_Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Edg/94.0.992.38'},
        {'User_Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.27 (KHTML, like Gecko) Chrome/94.0.4606.31 Safari/537.23 Edg/94.0.943.32'},
        {'User_Agent':'Mozilla/5.0 (Windows NT 6.1; Win32; x86) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.5021.11 Safari/237.36 Edg/94.0.992.38'}
    ]
    return choice(Header)

def DNS(http):
    import socket

    url = 'shiyixirui.cn'
    res = socket.getaddrinfo(url, None)
    print(res)

    ip = res[0][4][0]
    return ip

class resG(sessions.Session):
    def __init__(self,url,header=_headers(),params=None):
        super().__init__()
        self.request(method='get', url=url,params=params,headers=header)
        self.encoding = 'utf-8'
        self.JSON = loads(self.text)

if __name__ == '__main__':
    print(resG('https://baidu.com').text)
